package com.abc.qq.view.tcp;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class MyClient {
    public static void main(String[] args) {
        try {
            Socket socket = new Socket("127.0.0.1", 8888);

            InputStream is = socket.getInputStream();
            OutputStream os =  socket.getOutputStream();

            os.write("回家吧孩子".getBytes());

            byte[] cache = new byte[100];
            is.read(cache);
            System.out.println(new String(cache).trim());

            //清空缓存
            os.flush();

            os.close();
        } catch (IOException e) {
           e.printStackTrace();
        }
    }
}
